package io.gitee.zhangbinhub.admin.controller.inner

import cn.dev33.satoken.oauth2.processor.SaOAuth2ServerProcessor
import io.gitee.zhangbinhub.acp.boot.exceptions.WebException
import io.gitee.zhangbinhub.acp.boot.log.LogAdapter
import io.gitee.zhangbinhub.admin.api.CommonPath
import io.gitee.zhangbinhub.admin.base.BaseController
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 * @since JDK 11
 */
@Validated
@RestController
@RequestMapping(CommonPath.innerBasePath)
@Tag(name = "认证信息（内部接口）")
class InnerTokenController(logAdapter: LogAdapter) : BaseController(logAdapter) {
    @Operation(summary = "token相关请求", description = "处理所有 OAuth2 相关请求")
    @RequestMapping(value = ["/oauth/*"], produces = [MediaType.APPLICATION_JSON_VALUE])
    @Throws(WebException::class)
    fun oauth(): ResponseEntity<Any> =
        ResponseEntity.ok(SaOAuth2ServerProcessor.instance.dister())
}
